<template>
	<view style="margin: 0 25rpx;" v-if="userInfo">
		<view class="top-box">
			<image src="../../static/wallet/money.png" mode="scaleToFill" style="width: 66rpx;height: 66rpx;"></image>
			<view style="color: rgba(255, 255, 255, 0.64);margin-top: 20rpx;">{{$t('总金额')}}</view>
			<view style="font-size: 54rpx;font-weight: bold;margin-top: 20rpx;">{{userInfo.money}}</view>
		</view>
		<view class=" u-flex-row u-flex-y-center" style="margin-top: 50rpx;">
			<text class="font-34 bold ice-mr-20" >{{$t('总明细')}}</text>
			<u-icon name="arrow-down-fill" color="#FFFFFF" size="10"></u-icon>
		</view>
		<view>
			<view class="log-box u-flex-row" v-for="(item,idx) in list" :key="idx">
				<u--image :src="icon[item.type]" shape="circle" width="81rpx" height="81rpx" mode="scaleToFill"></u--image>
				<view class="u-flex-fill ice-ml-20">
					<view class="font-32 bold">{{$t(item.memo)}}</view>
					<view class="font-26 ice-mt-6" style="color: rgba(255, 255, 255, 0.38);">{{item.time}}</view>
				</view>
				<view class="font-30 red" v-if="item.money>=0">+{{item.money}}</view>
				<view class="font-30 green" v-else>{{item.money}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				info: null,
				userInfo:null,
				toCurrency: 'USDT',
				fromMoney: '',
				icon:{
					recharge:require('../../static/wallet/recharge.png'),
					withdraw:require('../../static/wallet/withdraw.png'),
					team:require('../../static/wallet/team.png'),
					tui:require('../../static/wallet/tui.png'),
					transfer:require('../../static/wallet/transfer.png'),
					game:require('../../static/wallet/transfer.png'),
				},
				param: {
					page: 1,
					size:20,
				},
				over: false,
				list: [],
				/* list: [
					{type:'recharge',memo:'充值',time:'2024-09-25 13:43:00',money:17},
					{type:'recharge',memo:'充值',time:'2024-09-25 13:43:00',money:17},
					{type:'withdraw',memo:'提现',time:'2024-09-25 13:43:00',money:-17},
					{type:'team',memo:'团队收益',time:'2024-09-25 13:43:00',money:17},
					{type:'tui',memo:'直推收益',time:'2024-09-25 13:43:00',money:17},
					{type:'transfer',memo:'转账',time:'2024-09-25 13:43:00',money:-17},
				], */
			}
		},
		async onLoad(e) {
			uni.setNavigationBarTitle({
				title: this.$t("我的钱包")
			});
			await uni.$ice.checkLogin()
			this.getUserInfo()
			this.getList()
		},
		onReachBottom() {
			console.log('onReachBottom')
			this.getList()
		},
		onPullDownRefresh() {
			this.list = [];
			this.over = false;
			this.param.page = 1;
			this.getList()
		},
		methods: {
			getUserInfo() {
				let tmp = uni.getStorageSync('userInfo')
				if (tmp) {
					this.userInfo = JSON.parse(tmp)
				}
				uni.$ice.post('user/index', {}, false).then(res => {
					uni.setStorageSync('userInfo', JSON.stringify(res.data));
					this.userInfo = res.data
					uni.stopPullDownRefresh()
			
				}).catch(err => {
			
				})
			},
			getList() {
				if (this.over) {
					return;
				}
				uni.$ice.post('wallet/gold_log', this.param, false).then(res => {
					if (this.param.page == 1) {
						this.list = res.data
					} else {
						this.list = this.list.concat(res.data);
					}
					if (res.data.length < this.param.size) {
						this.over = true;
					} else {
						this.param.page++;
					}
					uni.stopPullDownRefresh()
			
				}).catch(err => {
			
				})
			},
			goPage(url) {
				uni.navigateTo({
					url: url
				})
			},			
		}
	}
</script>

<style scoped>
	.red{
		color: #EF043B;
	}
	.green{
		color: #26AB6B;
	}
	.top-box{
		background: linear-gradient(119deg, #258CE9, #DA2B45);
		border-radius: 12rpx;
		margin: auto;
		text-align: center;
		padding: 54rpx 0 60rpx 0;
	}
	.log-box{
		background: #0E0E0E;
		border-radius: 12rpx;
		border: 1px solid #252525;
		padding: 30rpx 20rpx;
		margin-top: 25rpx;
	}
</style>